﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VOL;
using BLL;
using System.Data;
using System.Data.SqlClient;

namespace WebShoes.Admin
{
    public partial class HoaDonForm : System.Web.UI.Page
    {
        HoaDonBL _HoaDonBL = new HoaDonBL();
        DataTable dt = new DataTable();
        int maHoaDon = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (!IsPostBack)
            {
                string _maHoaDon = Request.QueryString["MaHoaDon"];
                if (_maHoaDon == null || _maHoaDon == "" || !int.TryParse(_maHoaDon, out maHoaDon))
                {
                    hdfMaHoaDon.Value = "0";
                }
                else
                {
                    dt = _HoaDonBL.searchMaHoaDon(maHoaDon);
                    
                    lblMaHoaDon.Text = _maHoaDon;
                    lblDienThoai.Text = dt.Rows[0]["DienThoai"].ToString();
                    lblDienThoaiDiDong.Text = dt.Rows[0]["DienThoaiDiDong"].ToString();
                    lblHoTenKhachHang.Text = dt.Rows[0]["HoTenKhachHang"].ToString();
                    lblEmail.Text = dt.Rows[0]["Email"].ToString();
                    lblDiaChi.Text = dt.Rows[0]["DiaChi"].ToString();
                    //lblTongTien.Text = dt.Rows[0]["TongTien"].ToString();
                    lblNgayGiaoHang.Text = dt.Rows[0]["NgayGiaoHang"].ToString();
                    //lblHoTenNguoiQuanLy.Text = dt.Rows[0]["HoTen"].ToString();
                    //lblTenDangNhap.Text = dtKH.Rows[0]["TenDangNhap"].ToString();
                    //lblDiaChi.Text = dtKH.Rows[0]["DiaChi"].ToString();
                    //lblEmail.Text = dtKH.Rows[0]["Email"].ToString();
                    //lblDienThoai.Text = dtKH.Rows[0]["DienThoai"].ToString();
                    //lblDienThoaiDiDong.Text = dtKH.Rows[0]["DienThoaiDiDong"].ToString();
                    //lblHoTenHoaDon.Text = dtKH.Rows[0]["HoTenHoaDon"].ToString();
                    //lblQuanHuyen.Text = dtQH.Rows[0]["TenQuanHuyen"].ToString();
                    //lblThanhPho.Text = dtTP.Rows[0]["TenThanhPho"].ToString();
                    hdfMaHoaDon.Value = _maHoaDon;
                }
            }
        }

        //protected void btnSave_Click(object sender, EventArgs e)
        //{
        //    HoaDonBL _HoaDonBL = new HoaDonBL();
        //    HoaDon _hoaDon = new HoaDon();
        //    _HoaDonBL.updateNgayGiaoHang(int.Parse(Request.QueryString["MaHoaDon"]), DateTime.Now.Date);
        //    //dt = _HoaDonBL.searchIDHoaDon(int.Parse(Request.QueryString["MaHoaDon"]));
        //    //_hoaDon.MaHoaDon = int.Parse(Request.QueryString["MaHoaDon"]);
        //    //_hoaDon.MaHangHoa = int.Parse(dt.Rows[0]["MaHangHoa"].ToString());
        //    //_hoaDon.MaKhachHang = int.Parse(dt.Rows[0]["MaKhachHang"].ToString());
        //    //try
        //    //{
        //    //    _hoaDon.NgayMua = DateTime.Parse(dt.Rows[0]["NgayMua"].ToString());
        //    //}
        //    //catch (Exception ex) { }
        //    //_hoaDon.SoLuong = int.Parse(dt.Rows[0]["SoLuong"].ToString());
        //    //_hoaDon.MaNguoiQuanLy = int.Parse(dt.Rows[0]["MaNguoiQuanLy"].ToString());
        //    //_hoaDon.NgayGiaoHang = DateTime.Now.Date;
        //    //_HoaDonBL.updateHoaDon(_hoaDon);
        //    Response.Redirect("~/Admin/HoaDonManagerForm.aspx");
        //}
    }
}